<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    var date = new Date()

    var year = date.getFullYear()  // 2021
    var month = date.getMonth() + 1  // 11
    var day = date.getDate() // 6

    var flag = date.getDay()  // 星期

    // 2021-12-6 星期一

    var arr = ['星期日','星期一','星期二','星期三','星期四','星期五','星期六']

    var str = year + '-' + month + '-' + day + ' ' + arr[flag]

    console.log(str )

  </script>
</body>
</html>